// 输入框组件实例

import { assignInWith } from 'lodash'
import type { inputConfigType } from '../../../../../types/index'
import BaseEntity from '../../BaseEntity'
import { uid } from 'uid'
import type { configType, slotFormConfigType } from '../../BaseEntity'
import { entityType } from '../..'
export default class InputEntity extends BaseEntity {
    

    constructor(config: configType, slotFormConfig: slotFormConfigType) {
        let baseConfig: configType = {
            class: ['draggable-form-hover'],
            style: { width: '100%' },
            field: 'Single_Input_' + uid(4),
            label: '单行输入框',
            hideLabel: false,
            required: false,
        }
        let baseSlotFormConfig = {
            modelValue: '',
            placeholder: '请输入点什么',
            maxLength: 20,
      
     
        }
        let componentConfig: inputConfigType = {
            placeholder: {
                type: 'input',
                formItemConfig: {
                    label: '输入提示'
                },
                formItemElement: {
                    modelValue: '',
                    placeholder: '请输入'
                }
            },
            maxLength: {
                type: 'inputNumber',
                formItemConfig: {
                    label: '最大输入长度'
                },
                formItemElement: {
                    modelValue: 0,
                    placeholder: '请输入'
                }
            }
        }

        super(
          entityType.input,
            assignInWith(baseConfig, config),
            assignInWith(baseSlotFormConfig, slotFormConfig),
            componentConfig
        )
        this.initSlotFormConfig()
    }
    initSlotFormConfig(){
   
      this.componentConfig.placeholder.formItemElement.modelValue =  this.slotFormConfig["placeholder"]
      this.componentConfig.maxLength.formItemElement.modelValue= this.slotFormConfig["maxLength"]
    }
}
